<!-- 尾部带按钮的输入框(搜索框) -->
<!-- 
    <myInput 
        placeholder='呼呼' //输入框的placeholder占位符
        @search='console'> //点击搜索按钮或者回车键 时触发的事件 (searchText)=> searchText = '输入框的内容'
    </myInput>
 -->
<template>
    <div style="display: inline-block;">

        <el-input 
            v-model='searchText' 
            size=small 
            astyle='width: 300px;' 
            :placeholder=' vPlaceholder || placeholder ' 
            clearable 
            @keydown.enter.native=' $emit("search",searchText) '>
            <el-button 
                slot="append" 
                icon="el-icon-search" 
                size=small 
                style="color: #FFF!important;
                    background-color: #409EFF!important;
                    border-color: #409EFF!important;
                    border-top-left-radius: 0;
                    border-bottom-left-radius: 0;
                    height: 32px;"
                @click=' $emit("search",searchText) ' 
                onmousedown='this.style.opacity=0.6' onmouseup='this.style.opacity=""' onmouseleave='this.style.opacity=""'></el-button>
        </el-input>

    </div>
</template>

<script>
    // import { Ajax }  from '@/api/myPost.js'
    // import api from '@/api/api.js'
    var dad, myModel;
    export default {
        ref: false,
        global: false,
        name: 'myInput',
        props: ['placeholder','myModel','dad','son','dadSon'],
        data: function () {
            return {
                vPlaceholder: '',
                searchText: ''
            }
        },
        watch: {
            searchText(val,old) {
                if(this.innerSet) return delete this.innerSet;
                // console.warn(val);
                myModel && ( 
                    this.innerSet = 1,
                    dad[myModel] = val 
                );
            }
        },
        methods: {
            
        },
        created() {
            dad = this.parseDadSon('myInput');
            myModel = this.myModel;
            if (myModel) {
                dad.myBind(myModel,val=>{
                    if(this.innerSet) return delete this.innerSet;
                    // console.error(val);
                    this.innerSet = 2;
                    this.searchText = val;
                });
            };
        },
        mounted() {
           
        }

    }
</script>

<style>
    
</style>